package com.hnu.highlynewapp.service.impl;

import com.hnu.highlynewapp.vo.PublishIdeaVo;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hnu.highlynewapp.utils.PageUtils;
import com.hnu.highlynewapp.utils.Query;

import com.hnu.highlynewapp.dao.BusinessIdeaDao;
import com.hnu.highlynewapp.entity.BusinessIdeaEntity;
import com.hnu.highlynewapp.service.BusinessIdeaService;

import javax.xml.crypto.Data;


@Service("businessIdeaService")
public class BusinessIdeaServiceImpl extends ServiceImpl<BusinessIdeaDao, BusinessIdeaEntity> implements BusinessIdeaService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BusinessIdeaEntity> page = this.page(
                new Query<BusinessIdeaEntity>().getPage(params),
                new QueryWrapper<BusinessIdeaEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void publish(PublishIdeaVo vo) {
        BusinessIdeaEntity businessIdeaEntity = new BusinessIdeaEntity();
        businessIdeaEntity.setBusinessId(vo.getBusinessId());
        businessIdeaEntity.setContent(vo.getContent());
        businessIdeaEntity.setTitle(vo.getTitle());
        businessIdeaEntity.setPublishTime(new Date());
        this.save(businessIdeaEntity);
    }
}